<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.doone.telmarket.domain.ibator.ServiceTypeExample"%>
<%@page import="com.doone.telmarket.domain.ibator.ServiceType"%>
<%@page import="com.doone.telmarket.domain.Service"%>
<%@ taglib prefix="se" uri="/WEB-INF/serviceTypeTag.tld"%>
<%
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");
	List<Activity> list = null;
  if(session.getAttribute("list")!=null){
	  list = (List)session.getAttribute("list");
	  if(list.size()==0)
		  return;
  }else{
	  return;
  }
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.doone.telmarket.domain.ServiceProduct"%>
<%@page import="com.doone.telmarket.domain.ServicePage"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.doone.telmarket.domain.Activity"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>main</title>
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/css/admin/style-admin.css"
	type="text/css" media="all" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>

<script src="${pageContext.request.contextPath}/js/jquery.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/js/jquery.ui.draggable.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.alerts.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/serviceOpration.js"
	type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/css/jquery.alerts.css"
	rel="stylesheet" type="text/css" media="screen" />
	<script src="${pageContext.request.contextPath}/fckeditor/fckeditor.js"
	type="text/javascript"></script>
<style type="text/css">

.file{border:1px solid #333333;color:#666666;background:#eeeeee;font:normal 12px Tahoma;height:18px}
</style>





<script type="text/javascript">
		function showImageEditor(number){
			document.getElementById("Layer2").style.display = "";
			var top = (document.body.clientHeight-200)/2+"px";
			var left = (document.body.clientWidth-760)/2+"px";
			var div = document.getElementById("Layer2");
			div.style.top = top;
			div.style.left = left;
			document.getElementById("imageNumber").value = number;
			showImageEdit();
		}
		function showImageEdit(){
			 document.getElementById("bgLayer").width = document.body.scrollWidth; 
			 document.all["bgLayer"].style.display="";
			 document.all["bgLayer"].style.height=document.body.scrollHeight;
			 document.getElementById("Layer2").style.display="";
			 timer=setInterval(moveImage,"100");
		}
		function hideImageEdit(){
			clearInterval(timer);
			document.all["bgLayer"].style.display="none";
			document.all["Layer2"].style.display="none";
		}
		function moveImage(){
			document.all["Layer2"].style.top=document.body.scrollTop+(document.body.clientHeight-200)/2;
			document.all["Layer2"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
		}
		function displayDiv(){
		   document.getElementById("Layer2").style.display = "none";
		   hideImageEdit();
		}	

		function uploadActivityIcon(contextPath){
			if($("#smallImage1").val()==""){
				jAlert("请选择图片",'消息');
				return ;
			}
			var typeValue = document.getElementById("imageNumber").value;
			$.ajaxFileUpload   
		    (   
		        {   
		            url:contextPath+'/admin/updateImage?updateType='+typeValue,    
		            secureuri:false,   
		            fileElementId:'smallImage1',   
		            dataType: '',   
		            success: function(data, status)   
		            {      
		               jAlert(status,'消息');
		               displayDiv();
		            },   
		            error: function (data, status, e)   
		            {   
		            	jAlert("保存文件失败",'消息');
		            	displayDiv();
		            }   
		        }   
		    )  
		}

		function saveAll(conPath){

			
			var title1  = $("#title1").val();
			var title2  = $("#title2").val();
			var title3  = $("#title3").val();
			var id1  = $("#id1").val();
			var id2  = $("#id2").val();
			var id3  = $("#id3").val();
			var url1 = $("#url1").val();
			var url2 = $("#url2").val();
			var url3 = $("#url3").val();
			var text1 = $("#text1").val();
			var text2 = $("#text2").val();
			var text3 = $("#text3").val();
			if(title1==""){
				jAlert("请输入第一个推荐条目的标题",'消息');
				return ;
				}
			if(title2==""){
				jAlert("请输入第二个推荐条目的标题",'消息');
				return ;
				}
			if(title3==""){
				jAlert("请输入第三个推荐条目的标题",'消息');
				return ;
				}

			if(url1==""){
				jAlert("请输入第一个推荐条目的链接",'消息');
				return ;
				}
			if(url2==""){
				jAlert("请输入第二个推荐条目的链接",'消息');
				return ;
				}
			if(url3==""){
				jAlert("请输入第三个推荐条目的链接",'消息');
				return ;
				}
			if(text1==""){
				jAlert("请输入第一个推荐条目的内容",'消息');
				return ;
				}
			if(text2==""){
				jAlert("请输入第二个推荐条目的内容",'消息');
				return ;
				}
			if(text3==""){
				jAlert("请输入第三个推荐条目的内容",'消息');
				return ;
				}
			$.ajax({
			    url: conPath+'/admin/saveOperation',
			    type: 'POST',
			    data: "title1="+title1+"&title2="+title2+"&title3="+title3+"&url1="+url1+"&url2="+url2+"&url3="+url3+"&text1="+text1+"&text2="+text2+"&text3="+text3+"&id1="+id1+"&id2="+id2+"&id3="+id3,
			    timeout: 5000,
			    error: function(){
			    	jAlert('保存数据失败','消息');
			    },
			    success: function(msg){
			    	jAlert('保存数据成功','消息');
			    }
			});
		}
	
</script>
</head>
<body>

<div style="z-index: 1;height: 1000">

<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0"
	class="CContent">
	<tr>
		<th class="tablestyle_title">主页右侧精彩促销推荐配置</th>
	</tr>
	<tr>
		<td class="CPanel">
		<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
			<tr align="center">
				<td class="TablePanel"></td>
			</tr>
			<tr>
				<TD width="100%">
				<fieldset style="height: 100%;" id="queryResult"><legend>精彩促销推荐配置</legend>
				<div id="serviceDiv" style="width: 80%">
				推荐一:<br><input type="hidden" name="id1" id="id1" value="<%=list.get(0).getId() %>">
				标题:<input type="text" name="title1" size="30" id="title1" value="<%=list.get(0).getTitle() %>"><br>
				链接:<input type="text" name="url1" size="50" id="url1" value="<%=list.get(0).getUrl() %>"><br>
				内容:<input type="text" name="text1" size="100" id="text1"  value="<%=list.get(0).getContent() %>"><br>
				图片(点击更改):<img alt="促销1" src="${pageContext.request.contextPath}/<%=list.get(0).getImagePath() %>" onclick="showImageEditor(1);"><br>
				
				<br><br>
				推荐二:<br><input type="hidden" name="id2" id="id2"  value="<%=list.get(1).getId() %>">
				标题:<input type="text" name="title2" size="30" id="title2"  value="<%=list.get(1).getTitle() %>"><br>
				链接:<input type="text" name="url2" size="50" id="url2" value="<%=list.get(1).getUrl() %>"><br>
				内容:<input type="text" name="text2" size="100" id="text2" value="<%=list.get(1).getContent() %>"><br>
				图片(点击更改):<img alt="促销2"    src="${pageContext.request.contextPath}/<%=list.get(1).getImagePath() %>"  onclick="showImageEditor(2);"><br>
				
				<br><br>
				推荐三:<br><input type="hidden" name="id3" id="id3"  value="<%=list.get(2).getId() %>">
				标题:<input type="text" name="title3" size="30" id="title3" value="<%=list.get(2).getTitle() %>"><br>
				链接:<input type="text" name="url3" size="50" id="url3" value="<%=list.get(2).getUrl() %>"><br>
				内容:<input type="text" name="text3" size="100" id="text3" value="<%=list.get(2).getContent() %>"><br>
				图片(点击更改):<img alt="促销3"  src="${pageContext.request.contextPath}/<%=list.get(2).getImagePath() %>"  onclick="showImageEditor(3);"><br>
				<input type="button" id="save3" value="保存更改" class="button" onclick="saveAll('${pageContext.request.contextPath}');">
				
				<br><br>
				</div>
				</fieldset>
			
				</TD>
			</TR>

		</TABLE>


		</td>
	</tr>
	<TR>
		<TD colspan="2" align="center" height="50px"></TD>
	</TR>
</TABLE>
</div></div>
<div id="bgLayer" style="float:left;position:absolute;background:#CCCCCC;left:0px;top:0px;width:100%;height:1000;filter:alpha(style=0,opacity=50);display:none;z-index:2;"></div>
<div id="Layer2"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传精彩促销LOGO图</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="file" id="smallImage1"><input type="hidden" id="imageNumber">
  		<input type="button"  class="button" id="smallImageUpload" onclick="uploadActivityIcon('${pageContext.request.contextPath}');" value="上传">
  		<input type="button" onclick="displayDiv();" class="button"  value="取消"　>
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  	
  </div>

</div>
</body>
</html>